<?php 

class Unit_Test_Abstract extends CI_Controller{
	public function __construct(){
		parent::__construct();
		$this->load->library('unit_test');
		$this->unit->use_strict(TRUE);
	}

	protected function run($test, $expected_result, $test_name, $notes){

		$notes = '<strong>Valor teste:</strong> ' . $this->stringliza($test) . '<br /><strong>Valor esperado:</strong> '
		.  $this->stringliza($expected_result) . '<br />' . 'Notas: ' . $notes;

		$this->unit->run ($test, $expected_result, $test_name, $notes);
	}

	private function stringliza($valor){
		switch (gettype ($valor)){
			case 'boolean':
				return $valor ? 'TRUE' : 'FALSE';
			case 'integer':
			case 'double':
			case 'string':
				return $valor;
			case 'object ':
			case 'array':
			case 'resource':
				$resultado = "Composto: \t{";
				foreach($valor as $indice => $value){
					$resultado = $resultado . "\t" . $indice . ' => ' . $this->stringliza($value);
				}
				return $resultado . "}\t";
			case 'NULL':
				return 'NULL';

		}
	}
}

?>